package com.mkz.core.common.util;

import org.jasypt.encryption.StringEncryptor;
import org.springframework.core.env.StandardEnvironment;

import com.ulisesbocchio.jasyptspringboot.encryptor.DefaultLazyEncryptor;

public class JasyptUtils {
	private static StringEncryptor stringEncryptor;
	
	static {
		System.setProperty("jasypt.encryptor.password", "cloud");//设置根密码
		stringEncryptor = new DefaultLazyEncryptor(new StandardEnvironment());
	}
	
//	public static void main(String[] args) {
//        System.out.println(stringEncryptor.encrypt("cloud"));
//        System.out.println(stringEncryptor.decrypt("dQQC+0VrQLpS1yz3uOQHdA=="));
//	}
	
	//加密
	public String encrypt(String plainString) {
		return stringEncryptor.encrypt(plainString);
	}
	//解密
	public String decrypt(String encodeString) {
		return stringEncryptor.decrypt(encodeString);
	}
}
